namespace Digitalmes.AvaloniaUI.ViewModels;

/// <summary>
/// 系统配置
/// </summary>
public sealed partial class SettingsViewModel : ViewModelBase
{
    [NotNull]
    public ObservableCollection<StandardParam>? Standards { get; set; }

    [RelayCommand]
    public Task ChangeStandard(string paramCode)
    {
        var param = Standards.First(s => s.ParamCode == paramCode);
        ShowToast($"修改成功, {param.ParamName}");

        return Task.CompletedTask;
    }

    public SettingsViewModel()
    {
        Standards = new([new StandardParam
        {
            ParamCode = "motor_torque",
            ParamName = "电机扭矩标准",
            MinLimit = -1,
            MaxLimit = 1,
            IsEnabled = true,
        },
        new StandardParam
        {
            ParamCode = "repeatability",
            ParamName = "重复定位精度",
            MinLimit = -1,
            MaxLimit = 1,
            IsEnabled = true,
        },
        new StandardParam
        {
            ParamCode = "tempareture",
            ParamName = "温度容忍范围",
            MinLimit = -1,
            MaxLimit = 1,
            IsEnabled = false,
        }]);
    }

    public class StandardParam : ObservableObject
    {
        public string? ParamCode { get; set; }

        public string? ParamName { get; set; }

        public double MinLimit { get; set; }

        public double MaxLimit { get; set; }

        public bool IsEnabled { get; set; }
    }
}
